<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>选择会员卡</title>
	<meta content="width=device-width,initial-scale=1.0,maximum-scale=1.0,minimum-scale=1.0,user-scalable=no" name="viewport">
	<link rel="stylesheet" href="css/reset.css">
	<link rel="stylesheet" href="css/bosscoach.css">
	<link rel="stylesheet" href="css/flexible.css">
	<link rel="stylesheet" href="css/vant.css">
	<script src="js/vue/vue.js"></script>
	<script src="js/vue/axios.js"></script>
	<script src="js/vue/qs.js"></script>
	<script src="js/vue/MD5.js"></script>
	<script src="js/jquery-3.3.1.min.js"></script>
	<script src="js/fontsize.js"></script>
	<script src="js/glabe.js"></script>
	<script src="js/jquery.min.js"></script>
	<script src="js/vue/vant.js"></script>
</head>
<body >
	<div id="app">
		<div class="under_line"></div>
		<div class="member_card">
			<p  class="member_card_title">会员卡</p>

			<div v-for="(item,index) in dataList" :key="item.id">
				<div class="year_card_list clearfix">
					<div class="entrance_sign fl">
						<p class="entrance_sign_txt">{{item.Cardname}}</p>
						<p class="entrance_sign_date">{{item.time}}</p>
						<p class="entrance_sign_in">{{item.Account}}</p>
					</div>
					<div class="remaining_day fr">
						<div class="remaining_day_txt">{{item.Surplus_str}}</div>
						<div style="margin-top: 0.18rem;text-align: center;" v-if="item.is_yy=='0'" >
							<img  :src="active==index? 'images/check_in.png' : 'images/check_not.png'" 
									class="check_in"
							 @click="checkShow(index)">
							<!-- <img v-else src="images/check_not.png" alt="" class="check_in" @click="checkIsShow(index)">  -->
					</div>
				</div>
			</div>
			</div>
			<div class="appointment_btn" @click="sumbit"><a href="#" style="color:#fff;">预约</a></div>
		</div>
		<div class="technicalSupport">由馆家提供技术支持</div>
	</div>
</html>
<script>
		var app = new Vue({
			el: '#app',
			data: {
				dataList:[],
				kcInfo:[],
				uid:'',
				data:'',
				strToObj:'',
				index:"",
				active:null,
				dataFrom:{
					uid:'',
					plan_id:'',
					key:'',
					date:'',
					currid:''
				}
			},
			created() {
				this.setCanS()
			},
			methods: {
				//设置参数
				setCanS(){
					let Request = new Object()
					Request = GetRequest()
					this.dataFrom.uid = Request['uid']
					this.dataFrom.plan_id = Request['plan_id']
					this.dataFrom.key = Request['key']
					this.dataFrom.date = Request['date']
					this.dataFrom.currid = Request['currid']
					this.getCardList()
				},
				//获取卡列表信息
				getCardList(){
					const params=this.dataFrom
					axios.get('/mobileapi/boss/curr.php?act=tk_yy_list',{params:params}).then(res => {	
						this.dataList=res.data.data.card_list
						for(var i=0;i<this.dataList.length;i++){
							this.dataList[i].checkShow=false
						}
						this.kcInfo=res.data.data.kc_info;
					}).catch(err => {
						// vant.Toast('请求发送失败，请重试');
					})
				},
				checkShow(index){
					this.index=index
					this.active=index
				},				
				sumbit(){
					var from={
						date: this.dataFrom.date,  //预约课程日期
						uid:this.dataFrom.uid,  //会员id
						plan_id:this.dataFrom.plan_id,  //课程计划表id
						key:this.dataFrom.key,  //课程key值
						cid:this.dataList[this.index].id,  //会员卡id
						stime:this.kcInfo.Stime,  //开始时间
						etime:this.kcInfo.Etime,  //结束时间
						csid:this.dataList[this.index].Csid  //会员卡设置表id
					}
					let froms = JSON.stringify(from);
					let sign = md5(froms);
					let params = {
							from:froms,
							sign:sign
					}
					axios.post('/mobileapi/boss/curr.php?act=tk_yy',
					Qs.stringify(params)).then(res=>{
						//console.log(res)
						let { msg, code} = res.data
						if (code !== 200) {
							window.vant.Toast.fail(msg)
						} else {
							window.vant.Toast.success('预约成功');
							this.timer = setTimeout(this.gomember, 2000);
							return false
							this.timer = setTimeout(this.list, 2000);
						}
					}).catch(err=>{
						// vant.Toast('请求发送失败，请重试');
					})
				},
				//预约成功后跳转的页面
				list(){
					window.location.href='curriculum_t_yue.html?uid='+this.dataFrom.uid+''
				},
				gomember(){
					window.location.href='memberLIst.html'
				},
			}
		})

</script>